import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from "element-ui"
import VueParticles from 'vue-particles'  
import "./utils/index";
import "element-ui/lib/theme-chalk/index.css"
import "./styles/global.less"
import { DB } from "@/utils";
import VCharts from 'v-charts'
import dataV from '@jiaminghi/data-view'


Vue.config.productionTip = false
Vue.use(dataV)
Vue.use(VueParticles) 
Vue.use(ElementUI)
Vue.use(VCharts)
Vue.prototype.$DB = DB
// 引入图表
// 定义路由守卫
router.beforeEach((to, from, next) => {
  console.log(to,from, next);
  let user = localStorage.getItem('loadingtToken')
  console.log(user);
  if(to.path !== '/login') {
    console.log('2');
    if(user){
      console.log('2212');
      // 已经登录
		  next()
    }else{
      // 登录页面正常放行
      next('/login')
    }
  }else {
   
     //清理localStore
     localStorage.removeItem('loadingtToken')
    next()
  }
  
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
